package day08;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class homework03 {

    /* *3.创建集合添加学生对象，学生对象的属性：name,age
     *把姓名和年龄拼接成：张三-23的字符串，并放到数组当中
     **/
    public static void main(String[] args) {
        List<Student> list = new ArrayList<>();
        Collections.addAll(list,new Student("张三",20),new Student("王五",45),
                new Student("刘刘",30),new Student("刘六",30));
        String[] infos=list.stream().map(homework03::studenttostring).toArray(String[]::new);
        System.out.println(Arrays.toString(infos));
    }
    public static String studenttostring(Student s){
        String info=s.getName().concat("-").concat(String.valueOf(s.getAge()));
        return info;
    }
}
